using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication2.Models.Mapping
{
    public class KitItemMap : EntityTypeConfiguration<KitItem>
    {
        public KitItemMap()
        {
            // Primary Key
            this.HasKey(t => t.ID);

            // Properties
            this.Property(t => t.KIT)
                .IsRequired()
                .HasMaxLength(10);

            this.Property(t => t.ITEM)
                .IsRequired()
                .HasMaxLength(10);

            this.Property(t => t.File_Primary_Key)
                .HasMaxLength(10);

            // Table & Column Mappings
            this.ToTable("KitItems");
            this.Property(t => t.ID).HasColumnName("ID");
            this.Property(t => t.KIT).HasColumnName("KIT");
            this.Property(t => t.ITEM).HasColumnName("ITEM");
            this.Property(t => t.QTY).HasColumnName("QTY");
            this.Property(t => t.File_Primary_Key).HasColumnName("File Primary Key");

            // Relationships
            this.HasRequired(t => t.Item1)
                .WithMany(t => t.KitItems)
                .HasForeignKey(d => d.KIT);
            this.HasRequired(t => t.Item2)
                .WithMany(t => t.KitItems1)
                .HasForeignKey(d => d.ITEM);

        }
    }
}
